<?php
class Hopdong_AjaxController extends Zendvn_Controller_Action {
		
	protected $_arrParam; //Mang tham so nhan duoc khi mot Action chay
	protected $_currentController; //Duong dan cua Controller
	protected $_actionMain; //Duong dan cua Action chinh
	
	public function init(){
		
		$this->_arrParam = $this->_request->getParams(); //Mang tham so nhan duoc khi mot Action chay
		$this->_currentController = '/' . $this->_arrParam['module'] . '/' . $this->_arrParam['controller']; //Duong dan cua Controller
		$this->_actionMain = '/' . $this->_arrParam['module'] . '/'	. $this->_arrParam['controller'] . '/index'; //Duong dan cua Action chinh
	
		//Truyen ra ngoai view
		$this->view->arrParam = $this->_arrParam;
		$this->view->currentController = $this->_currentController;
		$this->view->actionMain = $this->_actionMain;
	
		$siteConfig = Zend_Registry::get('siteConfig');
		$template_path = TEMPLATE_PATH . "/admin/" . $siteConfig['template']['admin'];
		$this->loadTemplate($template_path, 'template.ini', 'ajax');
		
		$language = Zend_Registry::get('language');
		$this->view->language = $language['language'];
	}
	
	public function loadSanphamAction() {
		$this->_helper->layout->disableLayout();
		
		$tblAjax = new Khachhang_Model_Ajax();
		
		$this->view->slbKhoahoc	 	= $tblAjax->itemInSelectbox($this->_arrParam, array('task' => 'get-khoahoc'));
		$this->view->slbLophoc 		= $tblAjax->itemInSelectbox($this->_arrParam, array('task' => 'get-lophoc'));
		$this->view->slbKhuyenmai 	= $tblAjax->itemInSelectbox($this->_arrParam, array('task' => 'get-khuyenmai'));
		
		if(isset($this->_arrParam['id_khoahoc'])){
			$this->view->Khoahoc	= $tblAjax->getItem($this->_arrParam, array('task'=>'get-khoahoc'));
		}
		if(isset($this->_arrParam['id_lophoc'])){
			$this->view->Lophoc	= $tblAjax->getItem($this->_arrParam, array('task'=>'get-lophoc'));
		}
		if(isset($this->_arrParam['id_khuyenmai'])){
			$this->view->Khuyenmai	= $tblAjax->getItem($this->_arrParam, array('task'=>'get-khuyenmai'));
		}
		
		$this->view->Khuyenmai = $tblAjax->listItem($this->_arrParam, array('task' => 'list-khuyenmai'));
	}
	
	public function ajaxKhoahocAction() {
		$this->_helper->layout->disableLayout();
		
		$tblAjax = new Khachhang_Model_Ajax();
		$this->view->Item = $tblAjax->getItem($this->_arrParam, array('task'=>'get-khoahoc'));
	}
	
	public function ajaxLophocAction() {
		$this->_helper->layout->disableLayout();
		
		$tblAjax = new Khachhang_Model_Ajax();
		$this->view->slbLophoc 		= $tblAjax->itemInSelectbox($this->_arrParam, array('task' => 'get-lophoc'));
	}
	
	public function jsonLophocAction() {
		$this->_helper->layout->disableLayout();
		
		$tblAjax = new Khachhang_Model_Ajax();
		$this->view->Item = $tblAjax->getItem($this->_arrParam, array('task'=>'get-lophoc'));
	}
	
	public function ajaxPhongbanAction() {
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
		$tblAjax = new Khachhang_Model_Ajax();
		$this->view->Item = $tblAjax->getItem($this->_arrParam, array('task'=>'get-phongban'));
	}
	
	public function ajaxNhanvienAction() {
		$this->_helper->layout->disableLayout();
	
		$tblAjax = new Khachhang_Model_Ajax();
		$this->view->slbLophoc 		= $tblAjax->itemInSelectbox($this->_arrParam, array('task' => 'get-lophoc'));
	}
	
	public function sodoDoanhthuAction() {
		//$this->_helper->layout->disableLayout();
	}
}
